<?php
namespace Admin\Controller;
use Think\Controller;


/**
*  
*/
class LoginController extends Controller
{
	

	public function login()
	{
		$this->display();
	}

	public function dologin()
	{
		$condition=array(
			'adminname'=>$_POST['adminname'],
			//'password'=>md5(I('post.password'))

			'password'=>md5($_POST['password'])
			);

		$adminModel=M('Admin');
		$admin=$adminModel->where($condition)->find();

		if($admin)
		{
			//是合法的用户
			session('admin',$admin);
			$this->redirect('Index/users');
		}
		else
		{
			$this->error('用户名口令错误！');
		}
	}

	public function logout()
	{
		session('admin',null);
		$this->redirect("login");

		//exit();
	}
}

?>